package net.sourceforge.peertwitter.core;

import java.io.Serializable;
import java.security.PublicKey;
import java.util.HashSet;
import java.util.Set;

import rice.p2p.commonapi.Id;

public class Profile implements Serializable, Comparable<Profile> {
	private String name;
	private PublicKey publicKey;
	private Set<Id> followings;
	private long timestamp;
	private Id id;
	
	public Profile(Id myId) {
		this.setId(myId);
		this.followings = new HashSet<Id>();
		this.name = "";
		this.publicKey = null;
		this.timestamp = -1;
	}

	private static final long serialVersionUID = 6597410562069621524L;


	public String getName() {
		return name;
	}
	
	public boolean isConsistent() {
		//XXX: to check the id against the public-key
		return true;
	}

	public PublicKey getPublicKey() {
		return publicKey;
	}

	public Set<Id> getFollowings() {
		return followings;
	}

	public long getTimestamp() {
		return this.timestamp;
	}

	public void setTimestamp(long timestamp) {
		this.timestamp = timestamp;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setPublicKey(PublicKey publicKey) {
		this.publicKey = publicKey;
	}

	public void setFollowings(Set<Id> followings) {
		this.followings = followings;
	}


	public void setId(Id id) {
		this.id = id;
	}

	public Id getId() {
		return id;
	}

	@Override
	public int compareTo(Profile o) {
		long compare = this.timestamp - o.timestamp;
		return compare < 0 ? -1 : compare > 0 ? 1 : 0;
	}


}
